﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using KRS.Model;


namespace KRS.ViewModel.HouseInfoVMs
{
    public partial class HouseInfoListVM : BasePagedListVM<HouseInfo_View, HouseInfoSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.Create, Localizer["Create"],"", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.Edit, Localizer["Edit"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.Delete, Localizer["Delete"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.Details, Localizer["Details"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.BatchEdit, Localizer["BatchEdit"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.BatchDelete, Localizer["BatchDelete"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.Import, Localizer["Import"], "", dialogWidth: 800),
                this.MakeStandardAction("HouseInfo", GridActionStandardTypesEnum.ExportExcel, Localizer["Export"], ""),
            };
        }


        protected override IEnumerable<IGridColumn<HouseInfo_View>> InitGridHeader()
        {
            return new List<GridColumn<HouseInfo_View>>{
                this.MakeGridHeader(x => x.LouPan),
                this.MakeGridHeader(x => x.Title),
                this.MakeGridHeader(x => x.UnitPrice),
                this.MakeGridHeader(x => x.MinTaoPrice),
                this.MakeGridHeader(x => x.MaxTaoPrice),
                this.MakeGridHeader(x => x.MianJi),
                this.MakeGridHeader(x => x.Address),
                this.MakeGridHeader(x => x.JuNum),
                this.MakeGridHeader(x => x.TingNum),
                this.MakeGridHeader(x => x.WeiNum),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<HouseInfo_View> GetSearchQuery()
        {
            var query = DC.Set<HouseInfo>()
                .CheckEqual(Searcher.LouPan, x=>x.LouPan)
                .CheckContain(Searcher.Title, x=>x.Title)
                .Select(x => new HouseInfo_View
                {
				    ID = x.ID,
                    LouPan = x.LouPan,
                    Title = x.Title,
                    UnitPrice = x.UnitPrice,
                    MinTaoPrice = x.MinTaoPrice,
                    MaxTaoPrice = x.MaxTaoPrice,
                    MianJi = x.MianJi,
                    Address = x.Address,
                    JuNum = x.JuNum,
                    TingNum = x.TingNum,
                    WeiNum = x.WeiNum,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class HouseInfo_View : HouseInfo{

    }
}
